home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
- #include <stat.h>
- #include <unistd.h>
-
- #include "LabMaker.h"
-
- #define kPathChar ':'
-
- static void MakeFullPath(char* partialPath, char* fullPath);
- extern CurrentState gCurrState;
-
- void Error(char* message, char *buffer, short index, char* fileName)
- {
- #pragma unused(index, buffer)
- printf("ERROR: %s\n file %s;\n %s\n", message, fileName, gCurrState.buffer);
- #if 0
- puts(" ");
- while (index-- > 0)
- putchar(' ');
- puts("^\n");
- #endif
- }
-
-
- void Warning(char* message, char *buffer, short index, char* fileName)
- {
- #pragma unused(index, buffer)
- printf("WARNING: %s\n; file %s;\n %s\n", message, fileName, gCurrState.buffer);
- #if 0
- puts(" ");
- while (index-- > 0)
- putchar(' ');
- puts("^\n");
- #endif
- }
-
-
- int GetOrMakeDirectory(char *path, short isFullPath)
- // Returns an error code, or 0 if successful
- {
- char fullPath[kFullPathLength];
-
- if (!isFullPath)
- MakeFullPath(path, fullPath);
- else
- strcpy(fullPath, path);
-
- return mkdir(fullPath, 0);
- }
-
- // Locate or create the specified file and open it
- FILE* GetOrMakeFile(char* fileName, char *path, short isFullPath)
- {
- char fullPath[kFullPathLength];
- short length;
- FILE* result;
-
- if (!isFullPath)
- MakeFullPath(path, fullPath);
- else
- strcpy(fullPath, path);
-
- // Make sure there's one final path seperator between the path
- // and the file name
- length = strlen(fullPath);
- if (*fileName != kPathChar) {
- fullPath[length++] = kPathChar;
- fullPath[length++] = '\0';
- }
-
- // Append the file name to the path name and open the file
- strcat(fullPath, fileName);
- result = fopen(fullPath, "w");
- return result;
- }
-
- // Locate or create the specified file
- int CopyFile(char* sourceFileName, char *sourcePath, char* copyPath, short isFullPath)
- {
- #pragma unused (sourceFileName, sourcePath, copyPath, isFullPath)
- DebugStr("\pCopyFile must be implemented");
- // <<< Write
- return -1;
- }
-
- // --- Utility functions
- void MakeFullPath(char* partialPath, char* fullPath)
- {
- getcwd(fullPath, kFullPathLength);
- // We have the working directory, so now append our partial path
- strcat(fullPath, partialPath);
- }
-